<template>
  <!-- 商品 item 项 -->
  <view class="cart-list">
    <!-- item 左，选中框和图片 -->
    <view class="cart-list-left">
      <radio :checked="cartList.goods_state" color="#bfa" @click="handleRadio" ></radio>
      <image :src="cartList.goods_small_logo" class="cart-list-img"></image>
    </view>
    <!-- item 右 -->
    <view class="cart-list--right">
      <view class="cart-list-des">
        {{cartList.goods_name}}
      </view>
      <view class="cart-list-box">
        <view class="cart-list-price">
          {{cartList.goods_price}}¥
        </view>
        <uni-number-box :min="1" :value="cartList.goods_count" @change="handleNumChange"></uni-number-box>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    methods: {
      // 为 radio 选中状态绑定点击事件
      handleRadio() {
        this.$emit('radio-change', {
          goods_id: this.cartList.goods_id,
          goods_state: !this.cartList.goods_state
        })
      },
      handleNumChange(val) {
        this.$emit('num-change', {
          goods_id: this.cartList.goods_id,
          goods_count: val
        })
      }
    },
    props: {
      cartList: {
        type: Object,
        default: {}
      }
    }
  }
</script>

<style lang="less">
  .cart-list {
    padding: 10rpx;
    display: flex;
    border-bottom: 1px solid #efefef;

    .cart-list-left {
      width: 40%;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .cart-list-img {
        width: 200rpx;
        height: 200rpx;
      }
    }

    .cart-list--right {
      padding: 10rpx;
      width: 60%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .cart-list-des {
        width: 100%;
        height: 50rpx;
        line-height: 50rpx;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space:nowrap;
        font-size: 13px;
      }

      .cart-list-box {
        display: flex;
        justify-content: space-between;

        .cart-list-price {
          font-size: 16px;
          color: #c00000;
        }
      }
    }
  }
</style>
